package com.linglan.common.api;

import com.linglan.common.constants.CommonConstants;
import lombok.AllArgsConstructor;
import lombok.Getter;

import javax.servlet.http.HttpServletResponse;

/**
 * 业务代码枚举
 */
@Getter
@AllArgsConstructor
public enum ResultCode implements IResultCode {

    /**
     * 操作成功
     */
    SUCCESS(CommonConstants.SUCCESS, "操作成功", ""),

    /**
     * 业务异常
     */
    FAILURE(CommonConstants.FAIL, "业务异常", ""),
    /**
     * 操作异常
     */
    OPERATE_FAILED(CommonConstants.FAIL, "操作异常", "operate.msg.failed"),

    /**
     * 请求未授权
     */
    UN_AUTHORIZED(HttpServletResponse.SC_UNAUTHORIZED, "请求未授权", ""),

    /**
     * bizCode为空
     */
    BIZ_CODE_NULL(HttpServletResponse.SC_UNAUTHORIZED, "bizCode为空", ""),

    /**
     * bizCode 不匹配
     */
    BIZ_CODE_NOT_MATCH(HttpServletResponse.SC_UNAUTHORIZED, "bizCode不匹配", ""),

    /**
     * 客户端请求未授权
     */
    CLIENT_UN_AUTHORIZED(HttpServletResponse.SC_UNAUTHORIZED, "客户端请求未授权", ""),

    /**
     * 404 没找到请求
     */
    NOT_FOUND(HttpServletResponse.SC_NOT_FOUND, "404 没找到请求", ""),

    /**
     * 消息不能读取
     */
    MSG_NOT_READABLE(HttpServletResponse.SC_BAD_REQUEST, "消息不能读取", ""),

    /**
     * 不支持当前请求方法
     */
    METHOD_NOT_SUPPORTED(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "不支持当前请求方法", ""),

    /**
     * 不支持当前媒体类型
     */
    MEDIA_TYPE_NOT_SUPPORTED(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE, "不支持当前媒体类型", ""),

    /**
     * 请求被拒绝
     */
    REQ_REJECT(HttpServletResponse.SC_FORBIDDEN, "请求被拒绝", ""),

    /**
     * 服务器异常
     */
    INTERNAL_SERVER_ERROR(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "服务器异常", ""),

    /**
     * 缺少必要的请求参数
     */
    PARAM_MISS(HttpServletResponse.SC_BAD_REQUEST, "缺少必要的请求参数", ""),

    /**
     * 请求参数类型错误
     */
    PARAM_TYPE_ERROR(HttpServletResponse.SC_BAD_REQUEST, "请求参数类型错误", ""),

    /**
     * 请求参数绑定错误
     */
    PARAM_BIND_ERROR(HttpServletResponse.SC_BAD_REQUEST, "请求参数绑定错误", ""),

    /**
     * 参数校验失败
     */
    PARAM_VALID_ERROR(HttpServletResponse.SC_BAD_REQUEST, "参数校验失败", ""),
    //通用 错误码
    /**
     * 参数校验失败
     */
    TOKEN_INVALID(CommonConstants.TOKEN_INVALID, "token失效", "common.token.invalid"),

    //admin 相关的resultCode
    ADMIN_LOGIN_FAIL(CommonConstants.FAIL, "账号或者密码有误", ""),
    //customer相关的resultCode
    CUSTOMER_PASSWORD_NOT_SAME(HttpServletResponse.SC_BAD_REQUEST, "密码和确认密码不一致", "customer.pwd_confirm_fail"),


    // 站点相关 开始
    SITE_ID_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "站点id不能为空", "site.id.notEmpty"),
    SITE_DISABLE(HttpServletResponse.SC_BAD_REQUEST, "站点不存在或不可用", "site.disable"),
    SITE_NAME_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "站点名称不能为空", "site.name.notEmpty"),
    SITE_SORT_WEIGHT_NOTNULL(HttpServletResponse.SC_BAD_REQUEST, "站点排序权重不能为空", "site.sortWeight.notnull"),
    SITE_DEFAULT_CURRENCY_TYPE_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "站点默认货币不能为空", "site.defaultCurrencyType.notEmpty"),
    SITE_DEFAULT_LANGUAGE_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "站点默认语言不能为空", "site.defaultLanguage.notEmpty"),
    SITE_ORIGIN_REGION_ID_NOTNULL(HttpServletResponse.SC_BAD_REQUEST, "站点归属国家或地区不能为空", "site.originRegionId.notnull"),
    SITE_ORIGIN_SUBORDINATE_REGIONS_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "站点归属地下级地区不能为空", "site.originSubordinateRegions.notEmpty"),
    SITE_ORIGIN_REGION_ID_OCCUPIED(HttpServletResponse.SC_BAD_REQUEST, "站点归属国家或地区已经被其他站点绑定", "site.originRegionId.occupied"),
    SITE_USED_REJECT_DELETE(HttpServletResponse.SC_BAD_REQUEST, "站点已经被使用，禁止删除", "site.used.reject.delete"),
    SITE_USER_DEFAULT_NULL(HttpServletResponse.SC_BAD_REQUEST, "没有查询到默认站点", "site.user.default.null"),
    // 站点相关 结束

    // 场馆相关 开始
    VENUE_ID_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "场地ID不能为空", "venue.id.notEmpty"),
    VENUE_DISABLE(HttpServletResponse.SC_BAD_REQUEST, "场地不存在或不可用", "venue.disable"),
    VENUE_NAME_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "场馆名称不能为空", "venue.name.notEmpty"),
    VENUE_NAME_EN_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "场馆英文名称不能为空", "venue.nameEn.notEmpty"),
    VENUE_SITE_ID_NOTNULL(HttpServletResponse.SC_BAD_REQUEST, "归属站点id不能为空", "venue.siteId.notnull"),
    VENUE_ADDRESS_COUNTRY_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "所属国家/地区不能为空", "venue.addressCountry.notEmpty"),
    VENUE_ADDRESS_PROVINCE_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "省不能为空", "venue.addressProvince.notEmpty"),
    VENUE_ADDRESS_CITY_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "市不能为空", "venue.addressCity.notEmpty"),
    VENUE_ADDRESS_DISTRICT_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "区不能为空", "venue.addressDistrict.notEmpty"),
    VENUE_ADDRESS_DETAILS_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "地址不能为空", "venue.addressDetails.notEmpty"),
    // 场馆相关 结束
    // 艺人相关 开始
    ARTIST_ID_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "艺人ID不能为空", "artist.id.notEmpty"),
    ARTIST_DISABLE(HttpServletResponse.SC_BAD_REQUEST, "艺人不存在或不可用", "artist.disable"),
    ARTIST_NAME_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "艺人名称不能为空", "artist.name.notEmpty"),
    ARTIST_NAME_EN_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "艺人英文名称不能为空", "artist.nameEn.notEmpty"),
    ARTIST_HEADSHOT_NOT_EMPTY(HttpServletResponse.SC_BAD_REQUEST, "艺人头像不能为空", "artist.headshot.notEmpty"),

    // 艺人相关 结束

    ;

    /**
     * code编码
     */
    final int code;
    /**
     * 中文信息描述
     */
    final String message;

    final String messageKey;

}
